<template>
	<view class="HMfilterDropdown" :class="{'setDropdownBottom':maskVisibility}" :style="{'top':menuTop+'rpx'}">
		<view class="nav">
			<!-- <image :src="moreIcon"></image>
			<p class="text">更多</p> -->
			<wyb-drop-down :choseItem="curIndex" class="HMfilterDropdown" ref="dropDown" activeColor="#1DD3B8" :options="options" @change="onHeaderSelect" @select="onItemSelect">
				<!-- 自定义模式开启时，这里可以放内容 -->
			</wyb-drop-down>
			
		</view>
	
	</view>
</template>
<script>
	import wybDropDown from '../../components/wyb-drop-down/wyb-drop-down.vue'
	export default {
		props: {
			curIndex: {
				type: Number,
				default: 0
			}
		},
		watch: {
			curIndex(newVal, oldVal) {
				this.curIndex = newVal
			}
		},
		components: {
			wybDropDown
		},
		data() {
			return {
				choseIndex: '',
				choseItem: '',
				defaultIndex: [0],
				options: [{
					header: '更多',
					// contents在自定义开启时可以不用传
					contents: [
					{ id: 1, name: '配电房1' },
					{ id: 2, name: '配电房2' },
					{ id: 3, name: '配电房3' },
					{ id: 4, name: '配电房4' },
					{ id: 5, name: '配电房5' },
					{ id: 6, name: '配电房6' },
					{ id: 7, name: '配电房7' },
					{ id: 8, name: '配电房8' },
					{ id: 9, name: '配电房9' },
					{ id: 10, name: '配电房10' },
					{ id: 11, name: '配电房11' },
					{ id: 12, name: '配电房12' }],
					custom: false // 该栏目开启自定义模式
				}],
				moreIcon: '../../static/image/index/more-icon.png'
			}
		},
		methods: {
			onHeaderSelect(res) {
				console.log(res)
			},
			onItemSelect(d) {
				this.choseItem = d.content
				let content = d.content
				// uni.showToast({
				// 	icon: 'none',
				// 	title: content.name
				// })
				this.$emit('click', d)
			}
		}
	}
</script>
<style lang="scss">
	.HMfilterDropdown {
		// flex-shrink: 0;
		width: 100%;
		height: 100%;
		// z-index: 997;
		// flex-wrap: nowrap;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		top: var(--window-top);
		left: 0;
		overflow-y: hidden;

		&.setDropdownBottom {
			bottom: 0;
		}

		view {
			display: flex;
			flex-wrap: nowrap;
		}
	}

	.region {
		flex: 1;
		height: 44px;
	}

	.nav {
		width: 100%;

		// height: px;
		z-index: 12;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		image:first-child {
			width: 36rpx;
			height: 36rpx;
		}

		.text {
			font-size: 20rpx;
			color: #1DD3B8;
		}

		transition: color .2s linear;

	}

	.mask {
		z-index: 10;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0);
		transition: background-color .15s linear;

		&.show {
			background-color: rgba(0, 0, 0, 0.5);
		}

		&.hide {
			display: none;
		}
	}
</style>
